﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace System8ToyMC
{
	public partial class PlotPopUp : UserControl
	{
		public PlotPopUp()
		{
			// Required to initialize variables
			InitializeComponent();
		}

        /// <summary>
        /// Set the histogram up in the grid!
        /// </summary>
        /// <param name="h"></param>
        public void SetHistogram(Histogram h)
        {
            Histogram our = h.CloneHistogram();

            HistoContainer.Children.Add(our);
            our.SetValue(Grid.ColumnProperty, 0);
            our.SetValue(Grid.RowProperty, 0);
            our.SetValue(Grid.ColumnSpanProperty, 1);
            our.SetValue(Grid.RowSpanProperty, 1);
        }

        /// <summary>
        /// Fired when something has happened that should cause the
        /// pop-up to close.
        /// </summary>
        public event Action ClosePopUp;

        /// <summary>
        /// Fire the event.
        /// </summary>
        private void OnClosePopup()
        {
            if (ClosePopUp != null)
            {
                ClosePopUp();
            }
        }

        /// <summary>
        /// User has clicked on "close".
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Close_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            OnClosePopup();
        }
    }
}